Run one case with many data rows
Run the same request several times with different values from a table, and check each row.
Before you start.
- A collection with a case that works with one set of values (Test a REST API end to end, or the Quick start).
- A
.csvor.jsonfile with your test data. Each row becomes one run of the case. The column names are the names you use in the case. - Permissions: Build Dataset, View Dataset, Update Test Case (Permissions).
Steps
-
Prepare the file. A CSV example with two rows:
code,expected_status100,200999,404 -
Send the file to the collection. The Datasets tab has no upload. Open Source in the left panel, upload the file, then open its ⋮ menu and choose Submit to API test. In the dialog, pick your collection and click Submit. See Submit to API test.
-
Check the dataset. Open the collection's Datasets tab. The file appears with the type ROW and its row count, and the status Ready. See Datasets tab.
-
Bind the dataset to the case. Open the case and go to the Data tab. Under Dataset, choose your dataset and click + Bind another dataset. It appears in the Bound datasets table with how to use it, for example
{{data.1.column}}. Click Save. See Data. -
Use the columns in the request. In the Request tab, put the column in the URL, query, headers or body using the number of the dataset in the table. For the example above:
GET /items/{{data.1.code}} -
Use the columns in the checks. In Assertions, set Expected to
{{data.1.expected_status}}for a STATUSEQUALSrule. -
Choose what happens when a row fails. On the Data tab, set On Row Failure to Continue (run the other rows) or Stop. The box ITERATIONS THIS CASE WILL PRODUCE shows how many runs to expect: with two rows, "2 iterations".
-
Publish and run. Publish and run the collection. Each row is a separate iteration.
Check the result
Open the run and open the case. The Iterations table lists every row with its outcome, expected value and actual value, so you can see which row failed. See Results, history and reports.
Rules to remember
- If you bind more than one dataset to a case, they are read row for row, so they must have the same number of rows. Otherwise the bind is refused (
DATASET_ROW_COUNT_MISMATCH). - A dataset cannot be deleted while a case uses it. Unbind it on the Data tab first.
- For a small table that only one case needs, you can create it inside the case instead. See Case-owned datasets.